<template>
	<view>
		<view class="page">
			<view class="con">
				<view class="tis">姓名</view>
				<view>{{yaofang.user.name}}</view>
			</view>
			<view class="con">
				<view class="tis">电话</view>
				<view>{{yaofang.user.tel}}</view>
			</view>
			<view class="con">
				<view class="tis">药方名称</view>
				<u-input
					placeholder="请输入药方名称"
					clearable
					v-model="yaofang.name"
					disabled
					style="border-bottom: 1rpx solid #F5F5F5;"
				></u-input>
			</view>
			<view class="con">
				<view class="tis">药方</view>
				<view class="bingzheng_list">
					<u-input
						class="yaofangbox" 
						type="textarea"
						placeholder="请输入药方名称"
						clearable
						disabled
						v-model="yaofang.text3"
					></u-input>
				</view>
			</view>
			<view class="btn_list">
				<u-button @click="yaofang_wancheng">完成打包</u-button>
				<u-button>返回</u-button>
			</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>
<script>
	import { yaoshi_get_yaofang_info,yaofang_wancheng } from '@/util/api/api.js';
	
	export default {
		data() {
			return {
				yaofang:{
					id:0,
					name:'',
					guanlian_zd:[],
					text1:'',
					user:{
						name:'',
						tel:''
					}
				}
			}
		},
		onLoad(e) {
			this.init_yaofang_page(e.id)
			
			uni.request({
				url:'https://zy.gn1866.com/index.php/patient/login/getCode?code=0f1oxd1w34Qmd139BH2w3efRTO2oxd1O',
				success(res) {
					console.log(res)
				}
			})
			
			let bz_list = getApp().globalData.yf_guanlian_zd
			
			if(bz_list !== undefined && bz_list.length>0){
				this.yaofang.guanlian_zd = bz_list
				getApp().globalData.yf_guanlian_zd = []
			}
		},
		methods: {
			init_yaofang_page(id){
				 
				let that = this
				yaoshi_get_yaofang_info({id}).then((res)=>{
					if (res.code==200) {
						let text = JSON.parse(res.data.text3)
						res.data.text3 = text.classesList[0].yaofang['text1']
						console.log(res)
						
						that.yaofang = res.data
					} else{
						that.showToast(res.message)
					}
				})
			},
			add_goto_zdpage(){
				getApp().globalData.yf_guanlian_zd =  this.yaofang.guanlian_zd

				uni.navigateTo({
					url: '../fenlei/fenlei'
				});
			},
			showToast(text) {
				this.$refs.uToast.show({
					title: text,
					// url: '/pages/user/index'
				})
			},
			yaofang_wancheng(id = 0){
				let that = this

				yaofang_wancheng({id}).then((res)=>{
					if (res.code==200) {
						// that.page_init()
						// that.hide_add_class_popup()
					} else{
						that.showToast(res.message)
					}
				})
			}
		}
	}
</script>
<style scoped>
.page{
	padding: 50rpx;
}
.tis{
	display:flex;
	justify-content: space-between;
	font-size: 30rpx;
	font-weight: bold;
	color: #666666;
	line-height: 77rpx;
}
.btn_list{
	width: 650rpx;
	margin-top: 140rpx;
	display: flex;
}
.btn_list .u-btn{
	width: 300rpx;
	height: 88rpx;
	background: #15BBA2;
	border-radius: 44px;
	color: #FFFFFF;
}
.bingzheng_list{
	height: 225rpx;
	background: #F5F5F5;
	border-radius: 8rpx;
	padding: 15rpx;
}
.yaofangbox{
	height: 225rpx;
	background: #F5F5F5;
	border-radius: 8rpx;
	border: 0;
	padding: 15rpx;
}
.li_item{
	display: inline-block;
	background: #FFFFFF;
	padding: 10rpx 20rpx;
	margin: 10rpx;
}
</style>